From ffc15bf9221af662277c36e4a36b3f7a30487bd2 Mon Sep 17 00:00:00 2001 From: Chun-wei Fan Date: Tue, 1 Aug 2017 16:05:57 +0800 Subject: [PATCH] Visual Studio builds: Adapt to new glib-mkenums glib-mkenums is now done in Python, but since the Visual Studio build environment (cmd.exe) does not support shebang lines, we need to call the interpretor explicitly to run the script. This means that we need to update on how we generate gsk/gskenumtypes.[c|h] in our projects, as at this point GTK+-3.91.x does not require a GLib installation that ships with the Python-fied glib-mkenums. As a result, we adapt to this by first using Python to call glib-mkenums. If this fails (where the output file becomes 0 in size), then we use PERL to call the glib-mkenums script. Note that during the build this will cause a warning message to be displayed, stating that '&' cannot be found, but due to the way Windows .bat script are done, we need to live with that until a solution can be found on this. This is likely a problem that does not exist in the Meson builds, as Meson will take care of calling the interpretor for us by looking at the shebang lines for our case. Also, clean up the .batin Windows batch script that is used to call glib-mkenums by using a for loop in there. --- win32/gen-enums.batin | 14 ++++++++------ win32/vs12/gsk-4.vcxprojin | 33 +++++++++------------------------ win32/vs12/gtk4-gen-srcs.props | 6 +++++- 3 files changed, 22 insertions(+), 31 deletions(-) diff --git a/win32/gen-enums.batin b/win32/gen-enums.batin index 64f2cd8666..a99b60a308 100644 --- a/win32/gen-enums.batin +++ b/win32/gen-enums.batin @@ -5,12 +5,14 @@ cd ..\gsk if exist gskenumtypes.h del gskenumtypes.h if exist gskenumtypes.c del gskenumtypes.c -call perl %1\bin\glib-mkenums ^ ---template gskenumtypes.h.template ^ +for %%f in (gskenumtypes.h gskenumtypes.c) do ^ +%2\python %1\bin\glib-mkenums ^ +--template %%f.template ^ #include "gsk.enum.headers" -&1> gskenumtypes.h +&1> %%f -call perl %1\bin\glib-mkenums ^ ---template gskenumtypes.c.template ^ +for %%f in (gskenumtypes.h gskenumtypes.c) do ^ +if %%~zf EQU 0 perl %1\bin\glib-mkenums ^ +--template %%f.template ^ #include "gsk.enum.headers" -&1> gskenumtypes.c +&1> %%f diff --git a/win32/vs12/gsk-4.vcxprojin b/win32/vs12/gsk-4.vcxprojin index db6f34dd1f..5b12f4ab73 100644 --- a/win32/vs12/gsk-4.vcxprojin +++ b/win32/vs12/gsk-4.vcxprojin @@ -222,32 +222,17 @@ - Generating GSK enumeration sources... - $(GenGSKEnumSrcs) - ..\..\gsk\gskenumtypes.h;..\..\gsk\gskenumtypes.c;%(Outputs) - Generating GSK enumeration sources... - $(GenGSKEnumSrcs) - ..\..\gsk\gskenumtypes.h;..\..\gsk\gskenumtypes.c;%(Outputs) - Generating GSK enumeration sources... - $(GenGSKEnumSrcs) - ..\..\gsk\gskenumtypes.h;..\..\gsk\gskenumtypes.c;%(Outputs) - Generating GSK enumeration sources... - $(GenGSKEnumSrcs) - ..\..\gsk\gskenumtypes.h;..\..\gsk\gskenumtypes.c;%(Outputs) + Generating GSK enumeration sources... + $(GenGSKEnumSrcs) + ..\..\gsk\gskenumtypes.h;..\..\gsk\gskenumtypes.c;%(Outputs) + Generating GSK enumeration sources... + $(GenGSKEnumSrcsX64) + ..\..\gsk\gskenumtypes.h;..\..\gsk\gskenumtypes.c;%(Outputs) - Generating GSK resource sources... - $(GenGSKRsrcSrcs) - ..\..\gsk\gskresources.h;..\..\gsk\gskresources.c;..\..\gsk\gsk.gresource.xml;%(Outputs) - Generating GSK resource sources... - $(GenGSKRsrcSrcs) - ..\..\gsk\gskresources.h;..\..\gsk\gskresources.c;..\..\gsk\gsk.gresource.xml;%(Outputs) - Generating GSK resource sources... - $(GenGSKRsrcSrcs) - ..\..\gsk\gskresources.h;..\..\gsk\gskresources.c;..\..\gsk\gsk.gresource.xml;%(Outputs) - Generating GSK resource sources... - $(GenGSKRsrcSrcs) - ..\..\gsk\gskresources.h;..\..\gsk\gskresources.c;..\..\gsk\gsk.gresource.xml;%(Outputs) + Generating GSK resource sources... + $(GenGSKRsrcSrcs) + ..\..\gsk\gskresources.h;..\..\gsk\gskresources.c;..\..\gsk\gsk.gresource.xml;%(Outputs) diff --git a/win32/vs12/gtk4-gen-srcs.props b/win32/vs12/gtk4-gen-srcs.props index c611d740aa..4837210044 100644 --- a/win32/vs12/gtk4-gen-srcs.props +++ b/win32/vs12/gtk4-gen-srcs.props @@ -45,7 +45,8 @@ echo $(Configuration) > ..\..\MSVC_$(Configuration)_Vulkan $(PythonDir)\python ..\replace.py --action=replace-var --input=..\..\gtk\libgtk4.manifest.in --output=..\..\gtk\libgtk4.manifest --var=EXE_MANIFEST_ARCHITECTURE --outstring=* $(PythonDirX64)\python ..\replace.py --action=replace-var --input=..\..\gtk\libgtk4.manifest.in --output=..\..\gtk\libgtk4.manifest --var=EXE_MANIFEST_ARCHITECTURE --outstring=* copy ..\..\demos\gtk-demo\demos.h.win32 ..\..\demos\gtk-demo\demos.h - (cd ..) & (call gen-enums.bat $(GlibEtcInstallRoot)) & (cd $(SolutionDir)) + (cd ..) & (call gen-enums.bat $(GlibEtcInstallRoot) $(PythonDir)) & (cd $(SolutionDir)) + (cd ..) & (call gen-enums.bat $(GlibEtcInstallRoot) $(PythonDirX64)) & (cd $(SolutionDir)) echo ^<?xml version='1.0' encoding='UTF-8'?^> > ..\..\gsk\gsk.gresource.xml echo ^<gresources^> >> ..\..\gsk\gsk.gresource.xml @@ -97,6 +98,9 @@ $(GlibEtcInstallRoot)\bin\glib-compile-resources.exe --sourcedir=..\..\gsk --c-n $(GenGSKEnumSrcs) + + $(GenGSKEnumSrcsX64) + $(GenGSKRsrcSrcs) -- 2.30.2